package cc.wsyw126.java.lintCode;

public class Valid {

    public boolean isPalindrome(String s) {
        if (s == null || s.length() == 0) return true;
        int length = s.length(), l = 0;
        StringBuffer sb = new StringBuffer();
        String ss;
        for (int i = 0; i < length; i++)
            if (Character.isLetter(s.charAt(i)))
                sb.append(s.charAt(i));
        ss = sb.toString();
        if (ss == null || ss.length() == 0) return true;
        String c = ss.toLowerCase();
        int clength = c.length() - 1;
        while (l != clength) {
            if (c.charAt(l) == c.charAt(clength)) {
                l++;
                if (l == clength) return true;
                clength--;
            } else return false;
        }
        return true;
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }

}
